using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;

namespace SeguradoraIA.Framework.Log
{
    public class SQLLogData : LogData
    {
        public SQLLogData(string statement, IEnumerable<SqlParameter> parameters)
        {
            Message = "SQL Statement";

            StringBuilder sb = new StringBuilder(statement);

            if(parameters!= null)
            {
                foreach (SqlParameter parameter in parameters)
                {
                    string aux;
                    if (parameter.Value == null)
                    {
                        aux = "null";
                    }else
                    {
                        aux = parameter.Value.ToString();
                    }
                    sb.Replace(parameter.ParameterName, aux);
                }
            }

            Information = sb.ToString();
        }
    }
}